package cn.zyx.basic.interceptor;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration // 声明当前类是一个spring的核心配置文件
public class PetHomeWebMvcConfigurer implements WebMvcConfigurer{

    @Autowired
    private LoginInterceptor loginInterceptor;

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(loginInterceptor)
                .addPathPatterns("/**")                         // 拦截所有资源
                .excludePathPatterns("/login/**")               // 放行登录下的所有资源
                .excludePathPatterns("/user/register/**")       // 放行用户注册下的所有资源
                .excludePathPatterns("/fastDfs/**")             // 放行文件的上传和删除的资源
                .excludePathPatterns("/shop/settlement")        // 放行店铺入住的资源
                .excludePathPatterns("/verifycode/smsCode")     // 放行短信验证
                .excludePathPatterns("/notify")                 // 放行支付宝支付异步回调
                .excludePathPatterns("/swagger-resources/**","/webjars/**","/v2/**","/swagger-ui.html/**"); // 放行swagger拦截

    }
}
